Repository navigation
fix: consolidated defect-hunt batch (agy) — selfedit #797 follow-ups, server security, cloud budgets, bench /v1/score perplexity & TTFT, FM/AppCore/Speech, and Mac app lifecycle/l10n - #810
Conversation
…, A-C3, A-C7, A-S5, A-S7)
goodmai
left a comment
There was a problem hiding this comment.
Final cross-review (claude → agy) — LGTM
Verified bcf55f7 against the delta-review findings (read-only).
-
CloudGate. Every reserve is released on throw, cancel and stream end:
GuardedDecisionEngineandCloudAnswerrelease in a shieldeddefer(CloudGate.swift:183-187,:221-225);routeToCloudReservedandrouteToCloudStreamrelease indeferandonFinish(ModelRouter.swift:313-342,:368-372).
reserveis synchronous on the actor, so it cannot deadlock: a second concurrent unpriced call is refused, not queued.peakCallCostis learned only from reported spend. The deadrouteToCloudis gone. -
Compile issues fixed.
RequestGateis internal, and the A-A4 test assertsstate.phaseinstead of readingprocess. -
onAdoptedStopWait. It is a test-only optional, nil in production, and it makes the overlap deterministic. The old code fails by time-out instead of passing by luck. NoTask.yieldorTask.sleep. -
NLL. The reference test against a full-sequence forward matches 6 rows to 6 targets, and
chunk: 2crosses 3 boundaries, all within 1e-4. -
RateLimit. The
normalizedPathchange is covered:/api/v1/health/returns 200 after a 429. -
Whole diff: no new comments, no banned primitives, no
Task.sleepin tests.
LOW, non-blocking:
- A model that never reports
usage.costreserves the wholeactiveLimiton every call, so concurrent calls to it are always refused. Consider a nonzero fallback estimate, or document the behaviour. - The refusal message counts the in-flight reservation as "spent". "committed" would be more accurate.
Merge on green CI.
…tual keys, fix hf: adapter & 413/SSE/auth-rate-limit (A-S1, A-S2, A-S3, A-S8, A-S9, A-S12)
…with in-flight reservations, fix assess side-effects & cascade stream metadata (A-S4, A-S6, A-S10, A-S11)
…ulti-task metrics, gateless pass, and explicit dataset errors (A-B5, A-B6, A-B7, A-B8, A-B12)
…neSupervisor stopAdopted reentrancy, VoiceReducer race, Library fit retry, and speech bounds (A-A2, A-A4, A-A5, A-A6, A-A8, A-A9, A-A12)
…ch, sync model switches, pre-check attachment sizes, fix image regen I/O & EN/RU Localizable.strings parity (A-A1, A-A3, A-A10, A-A11, A-A13)
|
Updated 3 legacy test assertions in
All 44 tests in |
bcf55f7 to
47917b4
Compare
Summary
Consolidated defect-hunt batch (
agy's half — 32 findings across SelfEdit, REST/MCP security, Cloud routing/budgets, Benchmarks/Scoring, FoundationModels/AppCore/Speech, and Mac App lifecycle/l10n, plus all 5#797review follow-ups and all cross-review follow-ups from#803,#805, and the pre-pushjjreview).Supersedes
#803and#805to run as a single CI batch before cuttingv0.13.0.Commits & Verified Fixes
Self-Rewriting & MCP (
d43651cc,#797review +A-C2,A-C3,A-C7,A-S5,A-S7) — previously LGTM on#803WeightCopyErrorrecoverability classification; pre-mutation.sharedHandleMutationBlocked; adapter built beforecompleteSubmit; 3-consecutive-failure abort with valid JSON quote-escaped observations; Turkish dotted-İ UTF-16 alignment inMathAnswerGrader; odd prose quote handling (A-C2);Int.maxslice overflow fix (A-C3); nested numeric array privacy fence resetting on non-numeric tokens (A-C7, verified against 150-layerEditModelSummary); MCPselfedit_startroot/regular-file/32 MiB/non-negative-finite checks (A-S5,A-S7).Server Security & Protocol Hygiene (
0f7a0a96,A-S1,A-S2,A-S3,A-S8,A-S9,A-S12) — previously LGTM on#805+RateLimitMiddlewarenormalizedPathfollow-upA-S1: ValidateGenerationRequest.validated()before cloud fallback on/v1/generate,/api/v1/generate,/api/v1/generate/stream, and MCPbasalt_generate(usingMCPFailure(error)), plus overflow-safeModelCatalog.estimateCost.A-S2: Gate all admin/control routes (/v1/models/{load,download,publish,convert*},DELETE /v1/models*,/v1/compose*,/v1/mcp/approvals*) from virtual keys using Hummingbird-equivalent path normalization (blocking trailing-slash and double-slash bypasses), isolate virtual-key rate buckets asvk:<id>, and log a startup notice when virtual keys are configured without--api-key. (Behavior note: admin routes fail closed with 403 when only virtual keys are set without--api-key.)A-S3: Preservehf:adapter prefix on/v1/models/convert.A-S8: Normalize body-limit lookup referencing controller constants (ModelsHubController.bodyLimit,ModelsConvertController.bodyLimit,ComposeController.bodyLimit) and return structured JSON413responses.A-S9: Fail/api/v1/generate/streambefore HTTP 200 on pre-stream errors and omitdata: [DONE]on terminal.error.A-S12(partial — 401-flood intentionally open): Unconditionally stripx-basalt-budget-key/x-basalt-rate-keyinRequestGuardMiddleware, fixRESTServer.logStartuphasAuth, and normalize public-path checks inRateLimitMiddleware. Pre-auth 401-flood rate limiting remains intentionally open to preserve theRateLimitTests.swift:80-84contract (unauthenticated 401 rejects before spending limiter budget).Cloud Routing & Budgets (
f8f35bd9,A-S4,A-S6,A-S10,A-S11)A-S4: Setusage.include = trueon non-streaming chat requests and record provider-reportedusage.cost.A-S6: In-flight cost reservations inCostTracker(multi-tier + single-tierModelRouter.route/routeCloudChain/routeToCloudStream) andCloudGate(GuardedDecisionEngine,CloudAnswerusingModelCatalogcost estimates) released indefer/onFinishunderwithTaskCancellationShieldafter cost recording.A-S10: MakeModelRouter.assessside-effect-free, count prompt tokens frommessageswhenpromptis empty, and update sticky session tier on both cloud execution (.strong) andrecordLocalOutcome(.weak).A-S11: Merge locally accepted tokens and TTFT into cascade stream metadata.Benchmarks & Teacher-Forced Scoring (
0b3d04f4,A-B5,A-B6,A-B7,A-B8,A-B12)A-B5: Streambasalt:throughputfor real TTFT (triggering onreasoning_content,reasoning, orcontentdeltas), never fabricate0.15 * totalMs, and exclude prefill fromdecode_tps.A-B6: Add optionalcompletion_textand teacher-forcedmean_nllto/v1/score(ScoreRequest/ScoreReport/MLXInferenceEngine+Score) and movebasalt:perplexityonto/v1/scoreinstead of 16 generated tokens (failing explicitly whenmean_nllis missing).A-B7: Treatmetricx24as lower-is-better inBenchmarkComparator.A-B8: Preserve per-tasktask[i].*metrics alongside aggregated flat means inBenchmarkRunnerand fail gateless suites when samples fail.A-B12: Fail explicitly on missing/unreadable/malformed explicit datasets acrossExternalHarnessAdapter,BasaltSystemOneAdapter, andTranslationBenchmarkAdapter, and failBasaltMoMAdapteron empty route labels.FoundationModels, AppCore & Speech (
48902216,A-A2,A-A4,A-A5,A-A6,A-A8,A-A9,A-A12)A-A2: Emitreasoning_effort: "none"alongsideenable_thinking: falseinBasaltFoundationRequest.A-A4: RunfinishAdoptedStopinside the awaitedadoptedStopTaskinEngineSupervisorso concurrentshutdown()/relaunch()never races with late.stopcleanup.A-A5: Cancel playback cleanly insideVoiceEffectswithout racing.stopPlaybackagainst.synthesize.A-A6: ClearfitAttemptedon transientfitFailedinLibraryReducer.A-A8: Throw transport error on truncated SSE streams missing[DONE]inBasaltFoundationTransportandEngineClient.A-A9: Resolve streamedtool_callsfragments byindexinChatDeltaDecoderand merge arguments inChatReducer.A-A12: Guard empty WAV recordings inAudioCaptureActorand validate source sample rate / PCM capacity bounds inAppleSpeechSynthesizer.Mac App Lifecycle, Media I/O & Localization (
bcf55f77,A-A1,A-A3,A-A10,A-A11,A-A13) — previously LGTM in pre-push reviewA-A1: PreserveBASALT_*env vars (includingBASALT_METALLIB) while refreshingCloudKeyson relaunch and auto-relaunch when env changes.A-A3: SyncconfiguredModel, supervisor launch args,UserDefaults, and loaded state across model switches and App Intents.A-A10: Pre-check regular file, extension, and<= 32 MiBoff@MainActorfor chat attachments and atomic temp copy for video IO.A-A11: Resolve image regeneration references asynchronously off@MainActorwith HTTP 400 error on missing files (removed syncData(contentsOf:)and invalid 8-byte placeholder header).A-A13: Replace hardcoded"All 91"with"All %lld", add missing interpolated format keys in EN & RULocalizable.strings, remove duplicate keys (354 unique keys, exact EN/RU parity), and enforce key parity & duplicate-free invariants inAppShipTests.Verification
swift build/swift test -Xswiftc -warnings-as-errors --enable-code-coverageacross all 18 targeted suites + 3× repetitions on all 7 regression suites.check_no_new_comments.swift origin/main,check_size_limits.swift origin/main --impact,check_concurrency_hatches.swift,check_changed_coverage.swift.